<style>
	page { background-color: #fff; }
	.comment-list { padding: 0 30rpx; background-color: #fff; }
	.comment-list .cell { padding: 40rpx 0; border-bottom: 1rpx solid #f2f2f2; }
	.comment-list .icon { margin-right: 20rpx; width: 68rpx; height: 68rpx; border-radius: 50%; overflow: hidden; }
	.comment-list .desc { }
	.comment-list .desc ._mobile { padding-bottom: 12rpx; }
	.comment-list .desc ._comment { padding: 20rpx 0 30rpx; line-height: 28rpx; color: #333; font-size: 28rpx; }
	.comment-list .desc ._pic { margin: 0 20rpx 20rpx 0; width: 160rpx; height: 160rpx; }
</style>

<template>
	<view>
		<an-nav-bar title="评价"></an-nav-bar>

		<template v-if="!listItems.length">
			<view class="empty">
				<image class="image" src="/static/image/empty.png"></image>
			</view>
		</template>
		<template v-else>
			<view class="comment-list">
				<block v-for="(list,pindex) in listItems" :key="pindex">
					<block v-for="(item,index) in list" :key="item.id">

						<view class="flex2 cell" @click="goPage(item)">
							<view class="flex-0 icon">
								<image mode="scaleToFill" class="image" :src="$common.binImage(item.customerPhoto)"></image>
							</view>
							<view class="flex-1 desc">
								<view class="_mobile">{{item.customerMobile | geTel}}</view>
								<view>
									<uni-rate size="24" color="#d3d3d3" activeColor="#aa8050" :readonly="true" :value="item.attitudeScore" />
								</view>

								<view class="_comment">{{item.comment}}</view>

								<view class="_pics">
									<view class="_pic" v-if="item.imgPath" @click="$common.previewImage(item.imgPath)">
										<image mode="aspectFill" class="image" :src="$common.binImage(item.imgPath)"></image>
									</view>
								</view>
							</view>
						</view>

					</block>
				</block>
			</view>
		</template>

	</view>
</template>

<script>
	import {
		orderListRequest as listRequest,
	} from "@/api/comment"

	export default {
		data() {
			return {
				storeId: '',
				orderId: '',
				projectId: '',

				formValue: {},
				listItems: [],
			}
		},
		onLoad(options) {
			if (options.storeId) {
				this.storeId = options.storeId
			}
			if (options.orderId) {
				this.orderId = options.orderId
			}
			if (options.projectId) {
				this.projectId = options.projectId
			}
		},
		onShow() {
			this.initData()
			this.getList()
		},
		methods: {
			initData() {
				this.formValue = {
					pageNum: 1,
					pageSize: 10,
					storeId: this.storeId,
					orderId: this.orderId,
					projectId: this.projectId,
				}
			},
			getList() {
				listRequest(this.formValue).then(res => {
					if (this.formValue.pageNum == 1) {
						this.listItems = []
					}

					if (res && res.rows && res.rows.length) {
						this.$set(this.listItems, this.formValue.pageNum - 1, res.rows)
						this.formValue.pageNum++
					}
				})
			},
		},
		onPullDownRefresh() {
			this.formValue.pageNum = 1
			this.getList()

			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			let length = this.listItems.length
			if (this.listItems[length - 1].length >= this.formValue.pageSize) {
				this.getList()
			}
		},
	}
</script>
